package com.shiguiwu.springmybatis.designpattern.proxy.mybatisspring;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;

/**
 * @description: 注册bean工厂
 * @author: stone
 * @date: Created by 2021/8/31 21:17
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.proxy.mybatisspring
 */
public class RegistryFactory implements BeanDefinitionRegistryPostProcessor {

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
        GenericBeanDefinition definition = new GenericBeanDefinition();
        definition.setBeanClass(MapperFactoryBean.class);
        definition.setScope("singleton");
        definition.getConstructorArgumentValues().addGenericArgumentValue(IUserDao.class);
        beanDefinitionRegistry.registerBeanDefinition("userDao", definition);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {

    }
}
